﻿#ifndef MEDIADEVICEDIALOG_H
#define MEDIADEVICEDIALOG_H

#include <QDialog>
#include <QBasicTimer>

namespace Ui {
class MediaDeviceDialog;
}

class QProgressBar;

class AudioVolume
{
public:
    explicit AudioVolume(QProgressBar* &progressBar)
        :volume(-1),timer_count(-1),bar(progressBar){}
    void stopAudioTimer();
    void handle_volume(int vol);
    void handle_timer_event();
private:
    int volume;
    int timer_count;
    QProgressBar* &bar;
};

class MediaDeviceDialog : public QDialog
{
    Q_OBJECT

public:
    explicit MediaDeviceDialog(QWidget *parent = 0);
    ~MediaDeviceDialog();

private slots:
    void slot_combo_camera_currentIndexChanged(int index);
    void slot_combo_output_currentIndexChanged(int index);
    void slot_combo_input_currentIndexChanged(int index);

    void slot_video_test(QPixmap pix);
    void slot_phone_test(int volume);
    void slot_speaker_test(int volume);

    void slot_start();

private:
    Ui::MediaDeviceDialog *ui;
    int deviceIndexVideo;
    int deviceIndexPhone;
    int deviceIndexSpeaker;

	int  video_channel_id_;
    int  phone_channel_id_;
    int  speaker_channel_id_;

    int video_timer_count;
    AudioVolume phone_volume;
    AudioVolume speaker_volume;
    QBasicTimer timer;
protected:
    void timerEvent(QTimerEvent *e);
signals:
    void camera_index_changed(int index);
    void input_index_changed(int index);
    void output_index_changed(int index);
};

#endif // MEDIADEVICEDIALOG_H
